<?php
namespace App\Service\Front;

use App\Service\BaseService as Service;

class BaseService extends Service
{
    //基础服务

    //返回参数
    public function toback($code = 0, $msg = '', $data = [], $total = 0)
    {
        $msg = $msg ? $msg : 'success';
        return array('code' => $code, 'msg' => $msg, 'data' => $data, 'total' => $total);
    }

    //通过token获取cid
    public function cidByToken($token)
    {
        $res = (array) $this->dbConn($this->dbUser)->where('token', $token)->first();
        if (empty($res)) {
            return 0;
        }
        return $res['cid'];
    }

    //通过token获取uid
    public function uidByToken($token)
    {
        $res = (array) $this->dbConn($this->dbUser)->where('token', $token)->first();
        if (empty($res)) {
            return 0;
        }
        return $res['id'];
    }
}